package com.itxiao.controller;

import com.itxiao.annotation.Token;
import com.itxiao.config.SystemConfig;
import com.itxiao.pojo.bo.Page;
import com.itxiao.pojo.dto.AddAddressDto;
import com.itxiao.pojo.dto.AddCollectDto;
import com.itxiao.pojo.vo.R;
import com.itxiao.service.UserAddressService;
import com.itxiao.service.UserCollectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;


/**
 * (UserCollect)表控制层
 *
 * @author makejava
 * @since 2025-10-17 14:54:38
 */
@RestController
@RequestMapping("admin/api/v1/collect")
@CrossOrigin
@Api(tags = "商品收藏模块")
public class UserCollectController {
    /**
     * 服务对象
     */
    @Resource
    private UserCollectService userCollectService;

    @ApiOperation("查询")
    @PostMapping("/list")
    @Token
    public R queryList(HttpServletRequest request, @RequestBody Page page) {
        return userCollectService.queryList(request.getHeader(SystemConfig.HEADER_TOKEN),page.getCurPage(),page.getPageSize());
    }
    @ApiOperation("查询是否被收藏")
    @PostMapping("/query-collect")
    @Token
    public R queryCollect(@RequestBody AddCollectDto dto, HttpServletRequest request) {
        return userCollectService.queryCollect(dto,request.getHeader(SystemConfig.HEADER_TOKEN));
    }

    @ApiOperation("新增收藏")
    @PostMapping("/add")
    @Token
    public R add(@RequestBody AddCollectDto dto, HttpServletRequest request) {
        return userCollectService.add(dto,request.getHeader(SystemConfig.HEADER_TOKEN));
    }

    @ApiOperation("删除收藏")
    @DeleteMapping("/delete/{id}")
    @Token
    public R deleteById(@PathVariable Integer id, HttpServletRequest request)  {
        return userCollectService.deleteById(id,request.getHeader(SystemConfig.HEADER_TOKEN));
    }
}

